﻿CREATE PROCEDURE [dbo].[ew_sp_install_cultures]
    @uid_culture_id UNIQUEIDENTIFIER,
    @i_lcid         INT,
    @vc_name        VARCHAR(512),
    @b_enabled      BIT,
    @vc_description VARCHAR(1024),
    @dt_datetime    DATETIME,
    @nvc_user       NVARCHAR(1024)
AS
    IF NOT EXISTS (SELECT 1 FROM ew_tbl_cultures WHERE ew_uid_culture_id = @uid_culture_id)
    BEGIN
        INSERT ew_tbl_cultures (
            ew_uid_culture_id, 
            ew_i_lcid, 
            ew_vc_name, 
            ew_b_enabled, 
            ew_vc_description, 
            ew_dt_created, 
            ew_nvc_created_by, 
            ew_dt_modified, 
            ew_nvc_modified_by)
        VALUES (
            @uid_culture_id, 
            @i_lcid, 
            @vc_name, 
            @b_enabled, 
            @vc_description, 
            @dt_datetime, 
            @nvc_user, 
            @dt_datetime, 
            @nvc_user)
    END
    ELSE
    BEGIN
        UPDATE ew_tbl_cultures SET
            ew_i_lcid           = @i_lcid,
            ew_vc_name          = @vc_name,
            ew_b_enabled        = @b_enabled,
            ew_vc_description   = @vc_description,
            ew_dt_modified      = @dt_datetime,
            ew_nvc_modified_by  = @nvc_user
        WHERE ew_uid_culture_id = @uid_culture_id
    END
RETURN 0
